package com.ztc.util;

import com.ztc.ZtcRefundRatio.bean.ZtcRefundRatioInfo;
import com.ztc.ZtcTransport.bean.ZtcTransport;
import com.ztc.ZtcTransportDefaultPercentage.bean.ZtcTransportDefaultPercentage;
import com.ztc.ZtcTransportPercentageScale.bean.ZtcTransportPercentageScale;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;


/**
 * 初始化各级公司提成比例
 * @author   jetvae
 */
public class ZtcCompanyScaleUtil {

    /**
     * 初始化设置运营公司返利用户比例
     * @param ztcTransport  公司信息
     * @return
     */
    public static ZtcTransport setOperationCompany(ZtcTransport ztcTransport, BigDecimal dealerUserLevelScale,BigDecimal commonUserLevelScale){
        //固定扣费（运营公司设置返利）
        ztcTransport.setFixedFeeDeduction(0);
        //分销商返佣比例（运营公司设置返利）
        ztcTransport.setDistributorRebateProportion(dealerUserLevelScale);
        //普通用户返佣比例（运营公司设置返利）
        ztcTransport.setUserRebateProportion(commonUserLevelScale);
        //税收比例（运营公司设置返利）
        ztcTransport.setRevenueProportion(new BigDecimal(0));
        return ztcTransport;
    }


    /**
     * 运营公司(注册，新增)退票扣费比例初始化设置
     * @param zid  公司ID
     * @return
     */
    public static HashMap<String,Object> setOperation(String zid){
        ZtcRefundRatioInfo ztcRefundRatioInfo=new ZtcRefundRatioInfo();
        ztcRefundRatioInfo.setCreateTransportId(zid);
        ztcRefundRatioInfo.setStatus("1");
        ztcRefundRatioInfo.setRatioName("系统默认退票扣费比例规则");
        ztcRefundRatioInfo.setCreateTime(new Date());
        ztcRefundRatioInfo.setCreateUserId("402880035e27eb08015e2815e0800000");
        ztcRefundRatioInfo.setCreateUsername("admin");
        ztcRefundRatioInfo.setRemark("发车前两小时不允许退票(含两小时),发车前一天(含24小时)退票扣实际支付票价的10%!");
        String ztcRefundRatio="[{'startTime':0,'endTime':2,'chargeScale':null,'isRefund':'2','disabled':'true'},{'startTime':2,'endTime':24,'chargeScale':10,'isRefund':'1','disabled':'false'}]";
        HashMap<String,Object> result=new HashMap<>();
        result.put("ztcRefundRatioInfo",ztcRefundRatioInfo);
        result.put("ztcRefundRatio",ztcRefundRatio);
        return result;
    }

    /**
     * 设置公司提成收益比例
     * @param ztcTransportDefaultPercentage 系统默认提成比例方案
     * @param type  公司类型（1省级，2地级，3运营，4车方）
     * @param cid   公司ID
     */
    public static ZtcTransportPercentageScale setCompanyPercentageScale(ZtcTransportDefaultPercentage ztcTransportDefaultPercentage,Integer type,String cid){
        ZtcTransportPercentageScale ztcTransportPercentageScale=new ZtcTransportPercentageScale();
        switch (type){
            case 1:
                ztcTransportPercentageScale.setIncomeScale(ztcTransportDefaultPercentage.getProvincialLevelScale()); break;
            case 2:
                ztcTransportPercentageScale.setIncomeScale(ztcTransportDefaultPercentage.getMunicipalLevelScale()); break;
            case 3:
                ztcTransportPercentageScale.setIncomeScale(ztcTransportDefaultPercentage.getOperationLevelScale()); break;
            case 4:
                ztcTransportPercentageScale.setIncomeScale(ztcTransportDefaultPercentage.getCarCutLevelScale()); break;
            default:break;
        }
        ztcTransportPercentageScale.setTransportId(cid);
        ztcTransportPercentageScale.setCreateTime(new Date());
        return ztcTransportPercentageScale;
    }

}
